﻿using LYR_RPA.models.enums;
using Newtonsoft.Json;
using System;

namespace LYR_RPA.models.entity
{
    public class Result<T> : EventArgs
    {
        [JsonProperty("code")]
        public int Code { get; set; }
        [JsonProperty("msg")]
        public string Msg { get; set; }
        [JsonProperty("data")]
        public T Data { get; set; }
        [JsonProperty("exMsg")]
        public string exMsg { get; set; }




        public static Result<T> ResultContent(ResultEnum resultEnum,T data)
        {
            return new Result<T>
            {
                Data = data,
                Msg = resultEnum.Msg,
                Code = resultEnum.Code,
                
            }; 
        }


        public static Result<T> ResultContent(ResultEnum resultEnum, string exMsg, T data)
        {
            return new Result<T>
            {
                Data = data,
                Msg = resultEnum.Msg,
                Code = resultEnum.Code,
                exMsg = exMsg
            };
        }

        public static Result<T> ResultContent(int code,string msg, T data)
        {
            return new Result<T>
            {
                Data = data,
                Msg = msg,
                Code = code
            };
        }


        public static Result<T> ResultContent(int code, string msg,string exMsg, T data)
        {
            return new Result<T>
            {
                Data = data,
                Msg = msg,
                Code = code,
                exMsg = exMsg
            };
        }
    }
}
